package com.parleys.helper;

import com.parleys.R;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.DialogInterface;

public class ConnectionErrorRunnable implements Runnable {

	private final Activity activity;
	private final ProgressDialog progressDialog;

	public ConnectionErrorRunnable(final Activity activity, final ProgressDialog progressDialog) {
		this.activity = activity;
		this.progressDialog = progressDialog;
	}

	@Override
	public void run() {
		progressDialog.dismiss();

		new AlertDialog.Builder(activity).setIcon(android.R.drawable.ic_dialog_alert) //
				.setTitle(activity.getString(R.string.connection_error_title)) //
				.setMessage(activity.getString(R.string.connection_error_description)) //
				.setPositiveButton(activity.getString(android.R.string.cancel), new DialogInterface.OnClickListener() {

					@Override
					public void onClick(DialogInterface dialog, int which) {
						activity.finish();
					}

				}).show();
	}

}
